import glob
import cv2

def bmp2jpg():
    glob_str = r'D:\data\240815fubahanxi\caitu\20241016hou\*.bmp'
    ls = glob.glob(glob_str)
    for ind, i in enumerate(ls):
        img = cv2.imread(i)
        save_name = i[:-3] + 'jpg'
        # cv2.imwrite(save_name, img)  #
        cv2.imwrite(save_name, img,[int(cv2.IMWRITE_JPEG_QUALITY), 80])  # 中等
        print(f'{ind}/{len(ls)} {save_name}')

bmp2jpg()